<template>
    <div>
    <div id="slider" class="mui-slider">
            <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                <div class="mui-scroll">
                    <a :class="['mui-control-item',item.id == 0 ? 'mui-active':'']" data-wid="tab-top-subpage-1.html" v-for="item in cates" :key="item.id">
                        {{ item.title }}
                    </a>
                </div>
            </div>
        </div>
    </div>
</template>

<style scoped>
    *{
        touch-action:pan-y;
    }
</style>

<script>
import { Toast } from "mint-ui";

//导入mui-js文件
import mui from '../../lib/mui/js/mui.min.js';


//使用这个插件移除严格模式:
//cnpm install babel-plugin-transform-remove-strict-mode
//{
//  "plugins": ["transform-remove-strict-mode"]
//}

export default {
    data(){
        return{
            cates:[]
        }
    },
    created(){
        this.getAllCategory();
    },
    mounted(){
        mui('.mui-scroll-wrapper').scroll({
            deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
        });
    },
    methods:{
        getAllCategory(){
            this.$http.get("https://www.sinya.online/api/getimgcategory").then(result => {
                if(result.body.status === 0){
                    result.body.message.unshift({title:'全部',id:0});
                    this.cates = result.body.message;
                }else{
                    Toast('分类获取失败..');
                }
            });
        }
    }
}
</script>
